app.controller('SignupFormController',[
    '$scope','accountService','$state',
    function($scope,accountService,$state){

        $scope.signup=function(){
            if($scope.form.password!==$scope.form.password2){
                $scope.authError='两次输入的密码不一致';
                return;
            }
            $scope.authError=undefined;
            accountService.createAsync($scope.form.name,$scope.form.email,$scope.form.password)
                .then(function(result){
                    $state.go('app.dashboard');  
                },function(x){
                    $scope.authError=x;
                });

        };
    }
]);